package com.xxx.video.commen.presenters;

import android.content.Context;

import androidx.annotation.NonNull;

import com.xxx.video.commen.views.CommonProgressDialog;


public abstract class BasePresenter<T extends IBaseView> {
    /**
     * context
     */
    public Context context;

    private T baseView;
    /**
     * progress dialog
     */
    public CommonProgressDialog mCommonProgressDialog;

    public BasePresenter(@NonNull Context context, T baseView) {
        this.context = context;
        this.baseView = baseView;
    }

    /**
     * unbind presenter
     */
    public void unBindPresenter() {
        context = null;
        baseView = null;
    }

    protected void showRootLayoutStatus(int status) {
        if (null != baseView) {
            baseView.showRootLayoutStatus(status);
        }
    }

    public T getBaseView() {
        return baseView;
    }

    /**
     * show progress dialog
     *
     * @param msg msg
     */
    public void showProgressDialog(String msg) {
        if (context != null) {
            mCommonProgressDialog = CommonProgressDialog.makeDialog(context, msg);
            mCommonProgressDialog.show();
        }
    }

    /**
     * dismiss dialog
     */
    public void hideProgressDialog() {
        if (mCommonProgressDialog != null) {
            mCommonProgressDialog.dismiss();
        }
    }
}
